#include "CStateManager.h"


CStateManager::CStateManager(IGamePlay *game)
{
	m_Game = game;
	m_CurrentState = NULL;
	m_NextState = NULL;
}

CStateManager::~CStateManager()
{

}


void CStateManager::Init()
{
	m_CurrentState = m_NextState = new CMainState(this);
	m_CurrentState->Init();
}

void CStateManager::Update()
{
	if( m_CurrentState != m_NextState )
	{
		m_CurrentState->Destroy();
		m_CurrentState = m_NextState;
		m_CurrentState->Init();
	}

	m_CurrentState->Update();
}

void CStateManager::Render()
{
	m_CurrentState->Render();
}

void CStateManager::Destroy()
{
	m_CurrentState->Destroy();
}

void CStateManager::SetState(IGameState *state)
{
	m_NextState = state;
}


